import request from '../utils/request'
// 文章页面 获取详情的接口
const getArticleDetailAPI = ({ artId }) => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${artId}`
  })
}

// 点击一关注状态接口
const followAutAPI = ({ autId }) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target: autId

    }
  })
}
// 取关作者
const unfollowAutAPI = ({ autId }) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/user/followings/${autId}`,
    data: {
      target: autId

    }
  })
}

// 喜欢文章的接口
const likeArtAPI = ({ artId }) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target: artId
    }
  })
}

// 不喜欢文章的接口
const dislikeArtAPI = ({ artId }) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${artId}`
  })
}

// 获取评论的列表
const getCommnetListAPI = ({ artId, offset, limit = 10 }) => {
  return request({
    method: 'GET',
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source: artId,
      offset,
      limit
    }
  })
}
// 评论点赞
const likeCmtAPI = ({ cmtId }) => {
  return request({
    method: 'POST',
    url: '/v1_0/comment/likings',
    data: {
      target: cmtId
    }
  })
}
// 评论取消赞
const dslikeCmtAPI = ({ cmtId }) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/comment/likings/${cmtId}`
  })
}

const publishCmtAPI = ({ artId, data }) => {
  return request({
    method: 'POST',
    url: '/v1_0/comments',
    data: {
      target: artId,
      content: data
    }
  })
}
export {
  getArticleDetailAPI,
  followAutAPI,
  unfollowAutAPI,
  likeArtAPI,
  dislikeArtAPI,
  getCommnetListAPI,
  likeCmtAPI,
  dslikeCmtAPI,
  publishCmtAPI
}
